<?
  require('functions.inc.php');

  $result = mysqli_query($_SESSION['db_connection'], "SELECT password FROM users WHERE username = '".$_POST['username']."'");
  $db_pass = mysqli_fetch_assoc($result)['password'];

  if($db_pass == md5($_POST['password']))
  {
    // login successful
    $_SESSION['loggedin'] = 1;
    echo "location.reload();";
  }
  else
  {
    // login failed!
    echo "\$( \"#log\" ).html( \"Login failed!\" ).delay( 2000 ).fadeOut( 1000 , function() { $( \"#log\" ).empty().show(); });";
  }
?>
